// Copyright (c) Microsoft Corporation. All rights reserved.

namespace Microsoft.Tools.CodeRunner.UnitTest
{
	using System;
	using Microsoft.VisualStudio.TestTools.UnitTesting;
	using System.Collections.Specialized;
	using Microsoft.Tools.CodeRunner;

	[TestClass] 
	public class TaggedStringTests
	{
		[TestMethod] 
		public void TaggedStringDefault()
		{
			ListDictionary dict = new ListDictionary();

			dict.Add("abc", "123");
			dict.Add("defgh", "7890");

			TaggedString tagged = new TaggedString();
			string input = 
			   //01234567890123456789012345678901234567890123456789
				"%xxx%abc%xxx%defgh%xxx%ABC%xxx%abcxx\nxxx%defgh";
			string result = tagged.Replace(input, dict);
			
			Assert.AreEqual("%xxx123xxx7890xxx123xxx%abcxx\nxxx%defgh", result);
		}

		[TestMethod] 
		public void TaggedStringNonDefault()
		{
			// Using a different IDictionary instance here
			HybridDictionary dict = new HybridDictionary();

			dict.Add("abc", "123");
			dict.Add("defgh", "7890");

			TaggedString tagged = new TaggedString();
			tagged.TagPrefix = "$(";
			tagged.TagSuffix = ")";
			string input = 
			   //01234567890123456789012345678901234567890123456789
				"xxx$(abc)xxx$(defgh)xxx$(ABC)yyy$(unknown)de$(fgh";
			string result = tagged.Replace(input, dict, TaggedStringOptions.CaseSensitive | TaggedStringOptions.RemoveUnknownTags);
			
			Assert.AreEqual("xxx123xxx7890xxxyyyde$(fgh", result);
		}
	}
}
